package ttot.channel;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class Source {

	private final String host;
	private final int port;

	public Source(String host, int port) {
		this.host = host;
		this.port = port;
	}

	public static void main(String[] args) {
		Source s = new Source("127.0.0.1", 8081);
		s.start();
	}

	public void start() {
		try {
			Socket socket = new Socket(host, port);
			OutputStreamWriter osw = new OutputStreamWriter(socket.getOutputStream());
			osw.write("Hello World\n");
			osw.close();
		} catch (UnknownHostException e) {
			throw new RuntimeException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
}
